package com.es.db.indexdb.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;

import com.es.db.indexdb.bean.Obj2Cloumn;
import com.es.db.indexdb.dao.BaseDao;
import com.es.db.indexdb.dao.Obj2CloumnDao;

public class Obj2CloumnDaoImpl extends BaseDao implements Obj2CloumnDao{

	public void addObj2Column(Obj2Cloumn obj2Cloumn) {

		String sql = "insert into t_obj2column (objid, columnid) values (?,?)";
		List<Object> params = new ArrayList<Object>();
		params.add(obj2Cloumn.getObjid());
		params.add(obj2Cloumn.getColumnid());
		getIndexDBTemplate().update(sql, params.toArray());
		
	
	}

	public List<Integer> getColumn(int objid) {
		String sql = "select columnid from t_obj2column where objid = ? ";
		List<Object> params = new ArrayList<Object>();
		params.add(objid);
		List<Integer> column = getIndexDBTemplate().query(sql, params.toArray(), new RowMapper<Integer> (){

			public Integer mapRow(ResultSet rs, int rowNum) throws SQLException {
				
				return rs.getInt("columnid");
			}
			
		});
		return column;
	}

}
